<template>
    <div class="Machines">
        <TabBlue :tabs="['查询条件']" :activeTab.sync="activeTab">
            <div slot="TabColContent" class="TabColContent">
                <div class="filterItem">
                    <div class="title"><i></i><span class="text">设备类别</span></div>
                    <div class="content">
                        <el-input placeholder="请输入内容" v-model="keyType" class="input-with-select">
                        </el-input>
                    </div>
                </div>
                <div class="filterItem">
                    <div class="title"><i></i><span class="text">设备组</span></div>
                    <div class="content">
                        <el-input placeholder="请输入内容" v-model="keyGroup" class="input-with-select">
                        </el-input>
                    </div>
                </div>
                <div class="filterItem">
                    <div class="title"><i></i><span class="text">设备状态</span></div>
                    <div class="content">
                        <el-input placeholder="请输入内容" v-model="keyStatus" class="input-with-select">
                        </el-input>
                    </div>
                </div>
                <el-button type="primary" icon="el-icon-search">搜索</el-button>
            </div>
        </TabBlue>
        <TabBlue :tabs="['设备列表']" :activeTab.sync="activeTab">
            <div slot="TabColContent" class="TabColContent">
                <el-collapse v-model="activeNames1" @change="handleChange">
                    <el-collapse-item title="设备列表" name="1">
                        <div class="machinesTable">
                            <div class="listBtn">
                                <el-button icon="el-icon-plus" type="success" plain>新增</el-button>
                                <el-button icon="el-icon-delete" type="danger" @click="deleteItem">删除</el-button>
                            </div>
                            <el-table ref="multipleTable" :data="tableData1" style="width: 100%" :max-height="560" :header-cell-style="{background:'#F3F4F7'}" @selection-change="handleSelectionChange">
                                <el-table-column type="selection"></el-table-column>
                                <el-table-column type="index" label="序号" align="center"></el-table-column>
                                <el-table-column prop="key1" label="类别" align="center"></el-table-column>
                                <el-table-column prop="key2" label="设备组" align="center"></el-table-column>
                                <el-table-column prop="key3" label="状态" align="center"></el-table-column>
                                <el-table-column prop="key4" label="设备编号" align="center"></el-table-column>
                                <el-table-column label="操作" align="center">
                                    <el-button icon="el-icon-edit" type="info" plain @click="$router.push('/machineeidt')">编辑</el-button>
                                    <!-- <el-button icon="el-icon-view" type="success" plain>查看</el-button> -->
                                </el-table-column>
                            </el-table>
                        </div>
                    </el-collapse-item>
                </el-collapse>
            </div>
        </TabBlue>
        <!-- <el-dialog title="提示" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
            <span>这是一段信息</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
            </span>
        </el-dialog> -->
    </div>
</template>
<script>
import TabBlue from '../../components/TabBlue.vue'

export default {
    components: {
        TabBlue,
    },
    data() {
        return {
            activeTab: '1',
            //搜索关键字
            keyType: '',
            keyGroup: '',
            keyStatus: '',

            //默认展开列表
            activeNames1: '1',

            tableData1: [
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
                { key1: 'aaa', key2: 'bbb', key3: 'ccc', key4: 'ddd' },
            ],

            //多选
            multipleSelection: []
        }
    },
    methods: {
        handleChange() {

        },
        deleteItem() {
        	if(this.multipleSelection.length == 0) {
        		this.$message({
        		    type: 'info',
        		    message: '没有选中列表项'
        		});
        		return
        	}
            this.$confirm('此操作将删除选中的列表项, 是否继续?', '提示', {
                type: 'warning'
            }).then(() => {
                this.toggleSelection()
                this.$message({
                    type: 'success',
                    message: '删除成功!'
                });
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });
        },
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },
        //切换选中
        toggleSelection(rows) {
            if (rows) {
            	//清除指定选中
                rows.forEach(row => {
                    this.$refs.multipleTable.toggleRowSelection(row);
                });
            } else {
            	//清除所有选中
                this.$refs.multipleTable.clearSelection();
            }
        },
    }
}
</script>
<style>
.Machines {
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
}

.Machines .TabBlue {
    margin-bottom: 20px;
}

.Machines .el-tabs__header {
    margin: 0;
}

.Machines .TabColContent {
    background-color: #fff;
    padding: 10px 20px;
    border-radius: 3px;
}

.Machines .TabColContent .filterItem {
    width: 25%;
    display: inline-block;
    margin-right: 20px;
}

.Machines .TabColContent .filterItem>.title {
    height: 30px;
    line-height: 30px;
    vertical-align: middle;
    margin-bottom: 10px;
}

.Machines .TabColContent .filterItem>.title:after {
    content: '';
    height: 100%;
    display: inline-block;
    vertical-align: middle;
}

.Machines .TabColContent .filterItem>.title i {
    display: inline-block;
    background: rgba(42, 88, 173, .9);
    width: 3px;
    height: 16px;
    vertical-align: middle;
    margin-right: 10px;
}

.Machines .TabColContent .filterItem>.title .text {
    display: inline-block;
    vertical-align: middle;
}

.Machines .TabColContent .filterItem:last-child {
    margin-right: 0;
}

.Machines .TabColContent .filterItem>.content {}

.Machines .TabColContent .el-collapse {
    border: none;
}

.Machines .TabColContent .el-collapse .el-collapse-item {
    border: none;
}
.Machines .TabColContent .el-collapse .el-collapse-item__header {
	font-size: 18px;
}
.Machines .TabColContent .el-collapse .el-collapse-item__wrap {
    border-bottom: none;
}

.Machines .TabColContent .el-collapse .el-collapse-item__content {
    padding-bottom: 0;
}

.Machines .TabColContent .el-table th {
    padding: 5px 0;
}

.Machines .TabColContent .el-table td {
    padding: 5px 0;
}

.Machines .TabColContent .el-table td .el-button {
    padding: 5px 10px;
    font-size: 13px;
}

.Machines .TabColContent .machinesTable .listBtn {
    height: 50px;
    line-height: 50px;
}

.Machines .TabColContent .machinesTable .listBtn .el-button {
    padding: 10px 20px;
    font-size: 13px;
}


</style>